using UnityEngine;

public class PlayerState
{
    private readonly string _animBoolName;
    private int _animHash;
    protected Core _core;

    protected bool _isAnimationFinshed;
    protected bool _isExitingState; //MARKER:�ڿγ���ʾ˵��bug�������ҿ�����������˼������״̬ת��ֻ���ڸ�״̬Exitǰ����
    protected Player _player;
    protected PlayerData _playerData;

    protected float _startTime;
    protected PlayerSM _stateMachine;

    public PlayerState(Player player, PlayerSM stateMachine, PlayerData playerData, string animBoolName, Core core)
    {
        _player = player;
        _stateMachine = stateMachine;
        _playerData = playerData;
        _animBoolName = animBoolName;
        _core = core;
    }

    public virtual void Enter()
    {
        DoChecks();
        _animHash = Animator.StringToHash(_animBoolName);
        _player.Anim.SetBool(_animHash, true); //MARKER:����ֻ����һ��boolֵ�����ƣ���Ϊ��ѧ��Ƶ�е���ʦ��playerAnimator�Ĵ�����ͬ
        _startTime = Time.time;

        _isAnimationFinshed = false;
        _isExitingState = false;
    }

    public virtual void Exit()
    {
        _player.Anim.SetBool(_animHash, false);
        _isExitingState = true;
    }

    public virtual void LogicUpdate()
    {
        //AnimationTrigger();
    }

    public virtual void PhysicsUpdate()
    {
        DoChecks();
    }

    public virtual void DoChecks()
    {
    }

    public virtual void AnimationTrigger()
    {
    }

    public virtual void AnimationFinshTrigger()
    {
        _isAnimationFinshed = true;
    }
}